package com.ytf.test.third;

/**
 * @author: YTF
 * @date: 2024/9/12 10:54
 * @version: 1.0
 * @description: 传递对象
 */
public class PassObject {
    static void f(Letter letter){
        letter.c='z';
    }
    public static void main(String[] args) {
        Letter letter = new Letter();
        letter.c = 'a';
        System.out.println("letter.c= "+letter.c);
        f(letter);
        System.out.println("letter.c= "+letter.c);
        /**
         * output:
         * letter.c= a
         * letter.c= z
         * 总结：
         *  传递对象到方法，不是复制对象而是传递引用句柄地址，所以方法中修改对象也会修改
         */
    }
}

class Letter{
    char c ;
}
